package com.nekonomics
package types

import doobie.Meta

enum PaymentStatus {
  case Waiting
  case Success
  case Closed


  override def toString: String = productPrefix.toLowerCase
  
}

object PaymentStatus {
  given Meta[PaymentStatus] = Meta[String].tiemap(fromString)(_.toString)

  def fromString(s: String): Either[String, PaymentStatus] = s match {
    case "waiting" => Right(Waiting)
    case "success" => Right(Success)
    case "closed" => Right(Closed)
    case other => Left(s"Invalid PaymentStatus: <$other>")
  }


}
